import DashboardUtil from "@/visual/commons/utils/dashboard-util";
import type DashboardComponentType from "@/visual/commons/types/dashboard-component-type";

/**
 * 公共样式生成器
 */
export default class CommonStyleGenerator {
    static containerStyleGenerator(comp: DashboardComponentType<any>): Object {
        let transform = '';
        if (comp.styleProps && comp.styleProps.transformRotate) {
            transform += ` rotate(${comp.styleProps?.transformRotate}deg)`
        }

        if (comp.styleProps && comp.styleProps.transformScale) {
            transform += ' ' + DashboardUtil.geetTransformScaleCssVal(comp.styleProps?.transformScale);
        }

        return {
            transform,
        };
    }

    static componentStyleGenerator(comp: DashboardComponentType<any>): Object {
        return {
            borderTopColor: comp.styleProps?.borderTop?.color,
            borderTopWidth: comp.styleProps?.borderTop?.width + "px",
            borderTopStyle: comp.styleProps?.borderTop?.style,
            borderBottomColor: comp.styleProps?.borderBottom?.color,
            borderBottomWidth: comp.styleProps?.borderBottom?.width + "px",
            borderBottomStyle: comp.styleProps?.borderBottom?.style,
            borderLeftColor: comp.styleProps?.borderLeft?.color,
            borderLeftWidth: comp.styleProps?.borderLeft?.width + "px",
            borderLeftStyle: comp.styleProps?.borderLeft?.style,
            borderRightColor: comp.styleProps?.borderRight?.color,
            borderRightWidth: comp.styleProps?.borderRight?.width + "px",
            borderRightStyle: comp.styleProps?.borderRight?.style,
        }
    }
}